/*
 * @Author: zhuxiaoyi
 * @Date: 2024-01-05 16:48:39
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2024-07-05 22:57:59
 * @Description:
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import * as path from "path";

const baseURL = "http://localhost"
// const baseURL = "http://192.168.101.207"


// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    //设置别名
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [vue()],
  server: {
    port: 3002, //启动端口
    hmr: {
      host: "localhost",
      port: 3002,
    },
    // 设置 https 代理
    proxy: {
      "/geoserver": {
        // target: "http://172.16.1.48:8055/geoserver",
        target: baseURL+":8055/geoserver",
        changeOrigin: true,
        rewrite: (path: string) => path.replace(/^\/geoserver/, ""),
      },
      "/algorithmApi": {
        target: baseURL+":7001/algorithmApi",
        // target: "http://10.70.38.11:8090/zyjy-sjy",
        changeOrigin: true,
        rewrite: (path: string) => path.replace(/^\/algorithmApi/, ""),
      },
      "/webSocket": {
        target: baseURL+":8001/webSocket",
        // target: "http://10.70.38.11:8090/zyjy-sjy",
        changeOrigin: true,
        rewrite: (path: string) => path.replace(/^\/webSocket/, ""),
      },
      '/tianditu': {
        target: 'https://t0.tianditu.gov.cn', 
        changeOrigin: true,
        rewrite: (path: string) => path.replace(/^\/tianditu/, ""),
      }
    },
  },
});
